*-------------------------------------------------------------------------------
*Project: School Closures
*This code: Submission Package - Graphs
*Author: Anelli, Galasso, Griselda
*-------------------------------------------------------------------------------
*Date created 14/05/22
*-------------------------------------------------------------------------------


************************************
**# GRAPHS - SWEDEN = PRE-PANDEMIC *
************************************

/* Figure_3: Changes in Educational Inputs Due to School Closure */

preserve

foreach y in inperson_teaching online_teaching act_hmwk_alone act_hmwk_superv act_extracurric act_other{
	reg `y'_min   pandemic if schoolkid==2, vce(cluster region_det )
	estimates store `y'_2	
	reg `y'_min   pandemic if schoolkid==3, vce(cluster region_det )
	estimates store `y'_3	
	reg `y'_min   pandemic if schoolkid==4, vce(cluster region_det )
	estimates store `y'_4	
}

coefplot (inperson_teaching_2) (online_teaching_2) (act_hmwk_superv_2) (act_hmwk_alone_2) (act_extracurric_2) (act_other_2)  (act_other_2) ///
	(inperson_teaching_3) (online_teaching_3) (act_hmwk_superv_3) (act_hmwk_alone_3) (act_extracurric_3) (act_other_3)  (act_other_3) ///
	(inperson_teaching_4) (online_teaching_4) (act_hmwk_superv_4) (act_hmwk_alone_4) (act_extracurric_4) (act_other_4), ///
	vertical keep(pandemic) yline(0) recast(bar) barwidth(0.04) pstyle(p1) ///
	fcolor(*.5) ciopts(recast(rcap)) citop  ///
	graphregion(color(white)) ///
	legend (order(1 "In-Person Teaching" 3 "Online Teaching" 5 "Supervised Homework" 7 "Unsupervised Homework" ///
	9 "Extracurricular Activities" 11 "Other Activities")) 

	gr_edit plotregion1.plot13.draw_view.setstyle, style(no)
	gr_edit plotregion1.plot14.draw_view.setstyle, style(no)
	gr_edit plotregion1.plot27.draw_view.setstyle, style(no)
	gr_edit plotregion1.plot28.draw_view.setstyle, style(no)

	gr_edit xaxis1.edit_tick 1 1 `" Lower Secondary "', tickset(major)
	gr_edit xaxis1.add_ticks 0.6625 `"Primary"', tickset(major)
	gr_edit xaxis1.add_ticks 1.3325 `"Upper Secondary"', tickset(major)

	gr_edit plotregion1.plot1.style.editstyle area(shadestyle(color(blue%50))) editcopy
	gr_edit plotregion1.plot2.style.editstyle area(linestyle(color(blue))) editcopy
	gr_edit plotregion1.plot15.style.editstyle area(shadestyle(color(blue%50))) editcopy
	gr_edit plotregion1.plot16.style.editstyle area(linestyle(color(blue))) editcopy		
	gr_edit plotregion1.plot29.style.editstyle area(shadestyle(color(blue%50))) editcopy
	gr_edit plotregion1.plot30.style.editstyle area(linestyle(color(blue))) editcopy	
	gr_edit plotregion1.plot3.style.editstyle area(shadestyle(color(ebblue%50))) editcopy
	gr_edit plotregion1.plot3.style.editstyle area(linestyle(color(ebblue))) editcopy	
	gr_edit plotregion1.plot4.style.editstyle area(linestyle(color(ebblue))) editcopy	
	gr_edit plotregion1.plot17.style.editstyle area(shadestyle(color(ebblue%50))) editcopy
	gr_edit plotregion1.plot17.style.editstyle area(linestyle(color(ebblue))) editcopy	
	gr_edit plotregion1.plot18.style.editstyle area(linestyle(color(ebblue))) editcopy	
	gr_edit plotregion1.plot31.style.editstyle area(shadestyle(color(ebblue%50))) editcopy
	gr_edit plotregion1.plot31.style.editstyle area(linestyle(color(ebblue))) editcopy	
	gr_edit plotregion1.plot32.style.editstyle area(linestyle(color(ebblue))) editcopy	
	gr_edit plotregion1.plot5.style.editstyle area(shadestyle(color(orange%50))) editcopy
	gr_edit plotregion1.plot5.style.editstyle area(linestyle(color(orange))) editcopy	
	gr_edit plotregion1.plot6.style.editstyle area(linestyle(color(orange))) editcopy	
	gr_edit plotregion1.plot19.style.editstyle area(shadestyle(color(orange%50))) editcopy
	gr_edit plotregion1.plot19.style.editstyle area(linestyle(color(orange))) editcopy	
	gr_edit plotregion1.plot20.style.editstyle area(linestyle(color(orange))) editcopy	
	gr_edit plotregion1.plot33.style.editstyle area(shadestyle(color(orange%50))) editcopy
	gr_edit plotregion1.plot33.style.editstyle area(linestyle(color(orange))) editcopy	
	gr_edit plotregion1.plot34.style.editstyle area(linestyle(color(orange))) editcopy	
	gr_edit plotregion1.plot7.style.editstyle area(shadestyle(color(green%50))) editcopy
	gr_edit plotregion1.plot7.style.editstyle area(linestyle(color(green))) editcopy	
	gr_edit plotregion1.plot8.style.editstyle area(linestyle(color(green))) editcopy	
	gr_edit plotregion1.plot21.style.editstyle area(shadestyle(color(green%50))) editcopy
	gr_edit plotregion1.plot21.style.editstyle area(linestyle(color(green))) editcopy	
	gr_edit plotregion1.plot22.style.editstyle area(linestyle(color(green))) editcopy
	gr_edit plotregion1.plot35.style.editstyle area(shadestyle(color(green%50))) editcopy
	gr_edit plotregion1.plot35.style.editstyle area(linestyle(color(green))) editcopy	
	gr_edit plotregion1.plot36.style.editstyle area(linestyle(color(green))) editcopy
	gr_edit plotregion1.plot9.style.editstyle area(shadestyle(color(purple%50))) editcopy
	gr_edit plotregion1.plot9.style.editstyle area(linestyle(color(purple))) editcopy	
	gr_edit plotregion1.plot10.style.editstyle area(linestyle(color(purple))) editcopy	
	gr_edit plotregion1.plot23.style.editstyle area(shadestyle(color(purple%50))) editcopy
	gr_edit plotregion1.plot23.style.editstyle area(linestyle(color(purple))) editcopy	
	gr_edit plotregion1.plot24.style.editstyle area(linestyle(color(purple))) editcopy	
	gr_edit plotregion1.plot37.style.editstyle area(shadestyle(color(purple%50))) editcopy
	gr_edit plotregion1.plot37.style.editstyle area(linestyle(color(purple))) editcopy	
	gr_edit plotregion1.plot38.style.editstyle area(linestyle(color(purple))) editcopy	
	gr_edit plotregion1.plot11.style.editstyle area(shadestyle(color(black%50))) editcopy
	gr_edit plotregion1.plot11.style.editstyle area(linestyle(color(black))) editcopy	
	gr_edit plotregion1.plot12.style.editstyle area(linestyle(color(black))) editcopy
	gr_edit plotregion1.plot25.style.editstyle area(shadestyle(color(black%50))) editcopy
	gr_edit plotregion1.plot25.style.editstyle area(linestyle(color(black))) editcopy	
	gr_edit plotregion1.plot26.style.editstyle area(linestyle(color(black))) editcopy
	gr_edit plotregion1.plot39.style.editstyle area(shadestyle(color(black%50))) editcopy
	gr_edit plotregion1.plot39.style.editstyle area(linestyle(color(black))) editcopy	
	gr_edit plotregion1.plot40.style.editstyle area(linestyle(color(black))) editcopy
	
	gr_edit yaxis1.title.text.Arrpush {bf:Change During Covid-19 Pandemic (Mins)}
	gr_edit xaxis1.title.text.Arrpush {bf:Student's Level of Education}

graph export "Figure_3.pdf", as(pdf) name("Graph") replace		

restore		

/* Figure_S3: Heterogeneous Effect of School Closure by Parental Income */
preserve

global controls "gender age hh_adults hh_children job_status_bef schoolkid_gender"	

foreach y in inperson_teaching online_teaching act_class act_hmwk_alone act_hmwk_superv act_extracurric act_other{
reg `y'_min   pandemic i.schoolkid $controls if education_3levels==1, vce(cluster region_det )
estimates store `y'_pe1	
reg `y'_min   pandemic i.schoolkid $controls if education_3levels==2, vce(cluster region_det )
estimates store `y'_pe2	
reg `y'_min   pandemic i.schoolkid $controls if education_3levels==3, vce(cluster region_det )
estimates store `y'_pe3	
}
	
coefplot (inperson_teaching_pe1) (online_teaching_pe1) (act_hmwk_superv_pe1) (act_hmwk_alone_pe1) (act_extracurric_pe1) (act_other_pe1)  (act_other_pe1) ///
	(inperson_teaching_pe2) (online_teaching_pe2) (act_hmwk_superv_pe2) (act_hmwk_alone_pe2) (act_extracurric_pe2) (act_other_pe2)  (act_other_pe2) ///
	(inperson_teaching_pe3) (online_teaching_pe3) (act_hmwk_superv_pe3) (act_hmwk_alone_pe3) (act_extracurric_pe3) (act_other_pe3), ///
	vertical keep(pandemic) yline(0) recast(bar) barwidth(0.04) pstyle(p1) ///
	fcolor(*.5) ciopts(recast(rcap)) citop  ///
	graphregion(color(white)) ///
	legend (order(1 "In-Person Teaching" 3 "Online Teaching" 5 "Supervised Homework" 7 "Unsupervised Homework" ///
	9 "Extracurricular Activities" 11 "Other Activities") size(small)) 
		
	gr_edit plotregion1.plot13.draw_view.setstyle, style(no)
	gr_edit plotregion1.plot14.draw_view.setstyle, style(no)
	gr_edit plotregion1.plot27.draw_view.setstyle, style(no)
	gr_edit plotregion1.plot28.draw_view.setstyle, style(no)

	gr_edit xaxis1.edit_tick 1 1 `"Secondary"', tickset(major)
	gr_edit xaxis1.add_ticks 0.6625 `"Lower than Secondary"', tickset(major)
	gr_edit xaxis1.add_ticks 1.3325 `"University"', tickset(major)

	gr_edit plotregion1.plot1.style.editstyle area(shadestyle(color(blue%50))) editcopy
	gr_edit plotregion1.plot2.style.editstyle area(linestyle(color(blue))) editcopy
	gr_edit plotregion1.plot15.style.editstyle area(shadestyle(color(blue%50))) editcopy
	gr_edit plotregion1.plot16.style.editstyle area(linestyle(color(blue))) editcopy	
	gr_edit plotregion1.plot29.style.editstyle area(shadestyle(color(blue%50))) editcopy
	gr_edit plotregion1.plot30.style.editstyle area(linestyle(color(blue))) editcopy	
	gr_edit plotregion1.plot3.style.editstyle area(shadestyle(color(ebblue%50))) editcopy
	gr_edit plotregion1.plot3.style.editstyle area(linestyle(color(ebblue))) editcopy	
	gr_edit plotregion1.plot4.style.editstyle area(linestyle(color(ebblue))) editcopy	
	gr_edit plotregion1.plot17.style.editstyle area(shadestyle(color(ebblue%50))) editcopy
	gr_edit plotregion1.plot17.style.editstyle area(linestyle(color(ebblue))) editcopy	
	gr_edit plotregion1.plot18.style.editstyle area(linestyle(color(ebblue))) editcopy	
	gr_edit plotregion1.plot31.style.editstyle area(shadestyle(color(ebblue%50))) editcopy
	gr_edit plotregion1.plot31.style.editstyle area(linestyle(color(ebblue))) editcopy	
	gr_edit plotregion1.plot32.style.editstyle area(linestyle(color(ebblue))) editcopy	
	gr_edit plotregion1.plot5.style.editstyle area(shadestyle(color(orange%50))) editcopy
	gr_edit plotregion1.plot5.style.editstyle area(linestyle(color(orange))) editcopy	
	gr_edit plotregion1.plot6.style.editstyle area(linestyle(color(orange))) editcopy	
	gr_edit plotregion1.plot19.style.editstyle area(shadestyle(color(orange%50))) editcopy
	gr_edit plotregion1.plot19.style.editstyle area(linestyle(color(orange))) editcopy	
	gr_edit plotregion1.plot20.style.editstyle area(linestyle(color(orange))) editcopy	
	gr_edit plotregion1.plot33.style.editstyle area(shadestyle(color(orange%50))) editcopy
	gr_edit plotregion1.plot33.style.editstyle area(linestyle(color(orange))) editcopy	
	gr_edit plotregion1.plot34.style.editstyle area(linestyle(color(orange))) editcopy	
	gr_edit plotregion1.plot7.style.editstyle area(shadestyle(color(green%50))) editcopy
	gr_edit plotregion1.plot7.style.editstyle area(linestyle(color(green))) editcopy	
	gr_edit plotregion1.plot8.style.editstyle area(linestyle(color(green))) editcopy	
	gr_edit plotregion1.plot21.style.editstyle area(shadestyle(color(green%50))) editcopy
	gr_edit plotregion1.plot21.style.editstyle area(linestyle(color(green))) editcopy	
	gr_edit plotregion1.plot22.style.editstyle area(linestyle(color(green))) editcopy
	gr_edit plotregion1.plot35.style.editstyle area(shadestyle(color(green%50))) editcopy
	gr_edit plotregion1.plot35.style.editstyle area(linestyle(color(green))) editcopy	
	gr_edit plotregion1.plot36.style.editstyle area(linestyle(color(green))) editcopy
	gr_edit plotregion1.plot9.style.editstyle area(shadestyle(color(purple%50))) editcopy
	gr_edit plotregion1.plot9.style.editstyle area(linestyle(color(purple))) editcopy	
	gr_edit plotregion1.plot10.style.editstyle area(linestyle(color(purple))) editcopy	
	gr_edit plotregion1.plot23.style.editstyle area(shadestyle(color(purple%50))) editcopy
	gr_edit plotregion1.plot23.style.editstyle area(linestyle(color(purple))) editcopy	
	gr_edit plotregion1.plot24.style.editstyle area(linestyle(color(purple))) editcopy	
	gr_edit plotregion1.plot37.style.editstyle area(shadestyle(color(purple%50))) editcopy
	gr_edit plotregion1.plot37.style.editstyle area(linestyle(color(purple))) editcopy	
	gr_edit plotregion1.plot38.style.editstyle area(linestyle(color(purple))) editcopy	
	gr_edit plotregion1.plot11.style.editstyle area(shadestyle(color(black%50))) editcopy
	gr_edit plotregion1.plot11.style.editstyle area(linestyle(color(black))) editcopy	
	gr_edit plotregion1.plot12.style.editstyle area(linestyle(color(black))) editcopy
	gr_edit plotregion1.plot25.style.editstyle area(shadestyle(color(black%50))) editcopy
	gr_edit plotregion1.plot25.style.editstyle area(linestyle(color(black))) editcopy	
	gr_edit plotregion1.plot26.style.editstyle area(linestyle(color(black))) editcopy
	gr_edit plotregion1.plot39.style.editstyle area(shadestyle(color(black%50))) editcopy
	gr_edit plotregion1.plot39.style.editstyle area(linestyle(color(black))) editcopy	
	gr_edit plotregion1.plot40.style.editstyle area(linestyle(color(black))) editcopy
			
	gr_edit yaxis1.title.text.Arrpush {bf:Change During the Covid-19 Pandemic (Mins)}
	gr_edit xaxis1.title.text.Arrpush {bf:Parental Education}
	gr_edit note.text = {}
		
	gr_edit note.style.editstyle size(vsmall) editcopy
	gr_edit yaxis1.title.style.editstyle size(small) editcopy

graph export "Figure_S3.pdf", as(pdf) name("Graph") replace		

/* Figure_S4: Heterogeneous Effect of School Closure by Parental Level of Digitization */

foreach y in inperson_teaching online_teaching act_class act_hmwk_alone act_hmwk_superv act_extracurric act_other{
reg `y'_min   pandemic i.schoolkid $controls if use_software_dailymore==0, vce(cluster region_det )
estimates store `y'_pe1	
reg `y'_min   pandemic i.schoolkid $controls if use_software_dailymore==1, vce(cluster region_det )
estimates store `y'_pe2
}

coefplot (inperson_teaching_pe1) (online_teaching_pe1) (act_hmwk_superv_pe1) (act_hmwk_alone_pe1) (act_extracurric_pe1) (act_other_pe1)  (act_other_pe1) ///
	(inperson_teaching_pe2) (online_teaching_pe2) (act_hmwk_superv_pe2) (act_hmwk_alone_pe2) (act_extracurric_pe2) (act_other_pe2)  (act_other_pe2), ///
	vertical keep(pandemic) yline(0) recast(bar) barwidth(0.04) pstyle(p1) ///
	fcolor(*.5) ciopts(recast(rcap)) citop  /// //title("Primary, Lower and Upper-secondary Students")
	graphregion(color(white)) ///
	legend (order(1 "In-Person Teaching" 3 "Online Teaching" 5 "Supervised Homework" 7 "Unsupervised Homework" ///
	9 "Extracurricular Activities" 11 "Other Activities") size(small)) 

	gr_edit plotregion1.plot13.draw_view.setstyle, style(no)
	gr_edit plotregion1.plot14.draw_view.setstyle, style(no)
	gr_edit plotregion1.plot27.draw_view.setstyle, style(no)
	gr_edit plotregion1.plot28.draw_view.setstyle, style(no)

	gr_edit xaxis1.major.delete_tick 1
	gr_edit xaxis1.add_ticks 0.75 `"Word/Spreadsheet Not Used Daily"', tickset(major)
	gr_edit xaxis1.add_ticks 1.2 `"Word/Spreadsheet Used Daily"', tickset(major)

	gr_edit plotregion1.plot1.style.editstyle area(shadestyle(color(blue%50))) editcopy
	gr_edit plotregion1.plot2.style.editstyle area(linestyle(color(blue))) editcopy
	gr_edit plotregion1.plot15.style.editstyle area(shadestyle(color(blue%50))) editcopy
	gr_edit plotregion1.plot16.style.editstyle area(linestyle(color(blue))) editcopy		
		
	gr_edit plotregion1.plot3.style.editstyle area(shadestyle(color(ebblue%50))) editcopy
	gr_edit plotregion1.plot3.style.editstyle area(linestyle(color(ebblue))) editcopy		
	gr_edit plotregion1.plot4.style.editstyle area(linestyle(color(ebblue))) editcopy			
	gr_edit plotregion1.plot17.style.editstyle area(shadestyle(color(ebblue%50))) editcopy
	gr_edit plotregion1.plot17.style.editstyle area(linestyle(color(ebblue))) editcopy		
	gr_edit plotregion1.plot18.style.editstyle area(linestyle(color(ebblue))) editcopy			
		
	gr_edit plotregion1.plot5.style.editstyle area(shadestyle(color(orange%50))) editcopy
	gr_edit plotregion1.plot5.style.editstyle area(linestyle(color(orange))) editcopy		
	gr_edit plotregion1.plot6.style.editstyle area(linestyle(color(orange))) editcopy			
	gr_edit plotregion1.plot19.style.editstyle area(shadestyle(color(orange%50))) editcopy
	gr_edit plotregion1.plot19.style.editstyle area(linestyle(color(orange))) editcopy		
	gr_edit plotregion1.plot20.style.editstyle area(linestyle(color(orange))) editcopy			
		
	gr_edit plotregion1.plot7.style.editstyle area(shadestyle(color(green%50))) editcopy
	gr_edit plotregion1.plot7.style.editstyle area(linestyle(color(green))) editcopy		
	gr_edit plotregion1.plot8.style.editstyle area(linestyle(color(green))) editcopy	
	gr_edit plotregion1.plot21.style.editstyle area(shadestyle(color(green%50))) editcopy
	gr_edit plotregion1.plot21.style.editstyle area(linestyle(color(green))) editcopy		
	gr_edit plotregion1.plot22.style.editstyle area(linestyle(color(green))) editcopy
		
	gr_edit plotregion1.plot9.style.editstyle area(shadestyle(color(purple%50))) editcopy
	gr_edit plotregion1.plot9.style.editstyle area(linestyle(color(purple))) editcopy		
	gr_edit plotregion1.plot10.style.editstyle area(linestyle(color(purple))) editcopy		
	gr_edit plotregion1.plot23.style.editstyle area(shadestyle(color(purple%50))) editcopy
	gr_edit plotregion1.plot23.style.editstyle area(linestyle(color(purple))) editcopy		
	gr_edit plotregion1.plot24.style.editstyle area(linestyle(color(purple))) editcopy			
						
	gr_edit plotregion1.plot11.style.editstyle area(shadestyle(color(black%50))) editcopy
	gr_edit plotregion1.plot11.style.editstyle area(linestyle(color(black))) editcopy		
	gr_edit plotregion1.plot12.style.editstyle area(linestyle(color(black))) editcopy
	gr_edit plotregion1.plot25.style.editstyle area(shadestyle(color(black%50))) editcopy
	gr_edit plotregion1.plot25.style.editstyle area(linestyle(color(black))) editcopy		
	gr_edit plotregion1.plot26.style.editstyle area(linestyle(color(black))) editcopy
	
	gr_edit yaxis1.title.text.Arrpush {bf:Change During the Covid-19 Pandemic (Mins)}
	gr_edit xaxis1.title.text.Arrpush {bf: Household Digitalization}
	gr_edit yaxis1.title.style.editstyle size(small) editcopy
	
graph export "Figure_S4.pdf", as(pdf) name("Graph") replace

restore	

// Figure_1: Teaching Hours before and during the Pandemic in Primary, Lower and Upper SecondarySchools

preserve

collapse (mean) mean_act_class= act_class_min (sd) sd_act_class=act_class_min (count) n=act_class_min, by(cntr pandemic schoolkid) 
		
generate hi_act_class = mean_act_class + invttail(n-1,0.025)*(sd_act_class / sqrt(n))
generate lo_act_class = mean_act_class - invttail(n-1,0.025)*(sd_act_class / sqrt(n))

		gen order=.
		replace order=1 if cntr==8
		replace order=2 if cntr==6
		replace order=3 if cntr==4
		replace order=4 if cntr==3
		replace order=5 if cntr==9
		replace order=6 if cntr==1
		replace order=7 if cntr==5
		replace order=8 if cntr==7
		
		gen 	pandemic_cntr= pandemic  		if order==1
		replace pandemic_cntr= pandemic+3   	if order==2
		replace pandemic_cntr= pandemic+6   	if order==3
		replace pandemic_cntr= pandemic+9   	if order==4
		replace pandemic_cntr= pandemic+12   	if order==5
		replace pandemic_cntr= pandemic+15  	if order==6
		replace pandemic_cntr= pandemic+18   	if order==7
		replace pandemic_cntr= pandemic+21   	if order==8

sort pandemic_cntr
list pandemic_cntr cntr pandemic, sepby(cntr)

*In Sweden, the school never closed for primary and lower secondary students therefore this amount need to be set to zero for this graph
replace mean_act_class=0 	if cntr==8 & inrange(schoolkid,2,3)
replace hi_act_class=0 		if cntr==8 & inrange(schoolkid,2,3)
replace lo_act_class=0 		if cntr==8 & inrange(schoolkid,2,3)
		
drop if schoolkid==1
twoway (bar mean_act_class pandemic_cntr if pandemic==0) ///
				 (bar mean_act_class pandemic_cntr if pandemic==1) ///
				 (rcap hi_act_class lo_act_class pandemic_cntr if cntr!=8 | inrange(schoolkid,4,4)),  ///
				 by(schoolkid, graphregion(color(white)) cols(1)) ///
				 legend(row(1) order(1 "In-Person Teaching" 2 "Online Teaching") ) ///
				 xlabel( 0.5 "SE*" 3.5 "NZ" 6.5 "GER" 9.5 "FRA" 12.5 "UK"   ///
					15.5 "AUT" 18.5 "ITA" 21.5 "PL" , noticks labsize(small))  graphregion(color(white)) ///
					ytitle("Minutes", size(small))
		gr_edit b1title.text = {}
		gr_edit note.text = {}	   
		gr_edit plotregion1.xaxis1[3].add_ticks 0.5 `"19 Days"', custom tickset(major) editstyle(tickstyle(textgap(3)) )
		gr_edit plotregion1.xaxis1[3].add_ticks 3.5 `"24 days"', custom tickset(major) editstyle(tickstyle(textgap(3)) )
		gr_edit plotregion1.xaxis1[3].add_ticks 6.5 `"24 days"', custom tickset(major) editstyle(tickstyle(textgap(3)) )
		gr_edit plotregion1.xaxis1[3].add_ticks 9.5 `"37 days"', custom tickset(major) editstyle(tickstyle(textgap(3)) )
		gr_edit plotregion1.xaxis1[3].add_ticks 12.5 `"39 days"', custom tickset(major) editstyle(tickstyle(textgap(3)) )
		gr_edit plotregion1.xaxis1[3].add_ticks 15.5 `"61 days"', custom tickset(major) editstyle(tickstyle(textgap(3)) )
		gr_edit plotregion1.xaxis1[3].add_ticks 18.5 `"78 days"', custom tickset(major) editstyle(tickstyle(textgap(3)) )
		gr_edit plotregion1.xaxis1[3].add_ticks 21.5 `"93 days"', custom tickset(major) editstyle(tickstyle(textgap(3)) )
		gr_edit plotregion1.subtitle[1].style.editstyle drawbox(no) editcopy
		gr_edit plotregion1.yaxis1[1].style.editstyle majorstyle(tickstyle(textstyle(size(vsmall)))) editcopy

graph export "Figure_1.pdf", as(pdf) name("Graph") replace
	
restore

/* Figure 2: Days of School Closure and Hours of Online Teaching */
* Overall

preserve
replace act_class=0 if pandemic==1 & inrange(schoolkid,2,3) & cntr==8 // sweden has zero days of school closure
collapse (mean) mean_act_class= act_class (sd) sd_act_class=act_class (count) n_act_class=act_class (mean) day_of_school_lost if pandemic==1 & inrange(schoolkid,2,4),  by(cntr pandemic)  

gen mean_act_class_min=mean_act_class*60
	la variable mean_act_class_min "Minutes of Remote Learning"

foreach y in act_class{
	generate hi_`y' = mean_`y' + invttail(n_`y'-1,0.025)*(sd_`y' / sqrt(n_`y'))
	generate lo_`y' = mean_`y' - invttail(n_`y'-1,0.025)*(sd_`y' / sqrt(n_`y')) 
}

sort cntr pandemic
order cntr pandemic

tab cntr if pandemic==1 & cntr!=2, sum(day_of_school_lost) 

eststo clear
eststo: reg mean_act_class_min day_of_school_lost  if pandemic==1 & cntr!=2 
***
quietly summ mean_act_class_min 				   if pandemic==1 & cntr!=2 	
loc mymean: di %8.2f r(mean) 	
estadd loc mD `mymean', replace
loc mysd: di %8.2f r(sd) 
estadd loc mS `mysd', replace
***
quietly summ day_of_school_lost 				   if pandemic==1 & cntr!=2 			
loc mymean_X: di %8.2f r(mean) 	
estadd loc mD_X `mymean_X', replace
loc mysd_X: di %8.2f r(sd) 
estadd loc mS_X `mysd_X', replace
***
local b_nobrazil: di %3.2f _b[day_of_school_lost]
local t = _b[day_of_school_lost]/_se[day_of_school_lost]
local p_nobrazil: di %3.2f 2*ttail(e(df_r),abs(`t'))

twoway (scatter mean_act_class_min day_of_school_lost if pandemic==1 & cntr!=2 & cntr!=6, mlabel(cntr) mlabsize(small)) ///
	   (scatter mean_act_class_min day_of_school_lost if pandemic==1 & cntr==6, mlabel(cntr) mlabsize(small) ///
	   mlabposition(6) mcolor(navy) mlabcolor(navy)) ///
	   (lfit mean_act_class_min day_of_school_lost if pandemic==1 & cntr!=2, lpattern(dash) ), ///
	xtitle(Days of school closure during the pandemic in 2020, size(medium)) ytitle(Minutes of online teaching activities, size(medium)) ///
	graphregion(color(white)) yscale(range(0 260)) ylabel(0(60)240) xscale(range(0 120)) xlabel(0(30)120) text(75 90 "slope:  `b_nobrazil'" 60 90 "p-value `p_nobrazil'", place(se)) legend(off)
gr_edit note.style.editstyle size(vsmall) editcopy
graph export "Figure_2a.pdf", as(pdf) name("Graph") replace

restore

* By school level

preserve
replace act_class=0 if pandemic==1 & inrange(schoolkid,2,3) & cntr==8 // sweden has zero days of school closure
collapse (mean) mean_act_class= act_class (sd) sd_act_class=act_class (count) n_act_class=act_class (mean) day_of_school_lost (mean) lost_day_2020 lost_day_2020_primary lost_day_2020_lowersecondary lost_day_2020_uppersecondary if pandemic==1 & inrange(schoolkid,2,4),  by(cntr pandemic schoolkid)

gen mean_act_class_min=mean_act_class*60
	la variable mean_act_class_min "Minutes of Remote Learning"
	la variable mean_act_class "Hours of Remote Leaning"

* Primary School
	
eststo: reg mean_act_class_min day_of_school_lost  if pandemic==1 & cntr!=2 & schoolkid==2
***
quietly summ mean_act_class_min 				   if pandemic==1 & cntr!=2 & schoolkid==2				
loc mymean: di %8.2f r(mean) 	
estadd loc mD `mymean', replace
loc mysd: di %8.2f r(sd) 
estadd loc mS `mysd', replace
***
quietly summ day_of_school_lost 				   if pandemic==1 & cntr!=2 & schoolkid==2				
loc mymean_X: di %8.2f r(mean) 	
estadd loc mD_X `mymean_X', replace
loc mysd_X: di %8.2f r(sd) 
estadd loc mS_X `mysd_X', replace
***
local b_nobrazil: di %3.2f _b[day_of_school_lost]
local t = _b[day_of_school_lost]/_se[day_of_school_lost]
local p_nobrazil: di %3.2f 2*ttail(e(df_r),abs(`t'))

twoway (scatter mean_act_class_min day_of_school_lost if pandemic==1 & schoolkid==2 & cntr!=2 & cntr!=6, mlabel(cntr) mlabsize(small)) ///
	   (scatter mean_act_class_min day_of_school_lost if pandemic==1 & schoolkid==2 & cntr==6, mlabel(cntr) mlabsize(small) ///
	   mlabposition(6) mcolor(navy) mlabcolor(navy)) ///
	   (lfit mean_act_class_min day_of_school_lost if pandemic==1 & schoolkid==2 & cntr!=2, lpattern(dash) ), ///
	xtitle(Days of school closure during the pandemic in 2020, size(medium)) ytitle(Minutes of online teaching activities, size(medium)) ///
	graphregion(color(white)) yscale(range(0 260))  ylabel(0(60)240) xscale(range(0 120)) xlabel(0(30)120) text(75 90 "slope:  `b_nobrazil'" 60 90 "p-value `p_nobrazil'", place(se)) legend(off)
gr_edit note.style.editstyle size(vsmall) editcopy
graph export "Figure_2b.pdf", as(pdf) name("Graph") replace

* Lower Secondary

eststo: reg mean_act_class_min day_of_school_lost  if pandemic==1 & cntr!=2 & schoolkid==3
****
quietly summ mean_act_class_min 				   if pandemic==1 & cntr!=2 & schoolkid==3				
loc mymean: di %8.2f r(mean) 	
estadd loc mD `mymean', replace
loc mysd: di %8.2f r(sd) 
estadd loc mS `mysd', replace
***
quietly summ day_of_school_lost 				   if pandemic==1 & cntr!=2 & schoolkid==3				
loc mymean_X: di %8.2f r(mean) 	
estadd loc mD_X `mymean_X', replace
loc mysd_X: di %8.2f r(sd) 
estadd loc mS_X `mysd_X', replace
***
local b_nobrazil: di %3.2f _b[day_of_school_lost]
local t = _b[day_of_school_lost]/_se[day_of_school_lost]
local p_nobrazil: di %3.2f 2*ttail(e(df_r),abs(`t'))

twoway (scatter mean_act_class_min day_of_school_lost if pandemic==1 & schoolkid==3 & cntr!=2 & cntr!=6, mlabel(cntr) mlabsize(small)) ///
	   (scatter mean_act_class_min day_of_school_lost if pandemic==1 & schoolkid==3 & cntr==6, mlabel(cntr) mlabsize(small) ///
	   mlabposition(6) mcolor(navy) mlabcolor(navy)) ///
	   (lfit mean_act_class_min day_of_school_lost if pandemic==1 & schoolkid==3 & cntr!=2, lpattern(dash) ), ///
	xtitle(Days of school closure during the pandemic in 2020, size(medium)) ytitle(Minutes of online teaching activities, size(medium)) ///
	graphregion(color(white)) yscale(range(0 260))  ylabel(0(60)240) xscale(range(0 120)) xlabel(0(30)120) text(75 90 "slope:  `b_nobrazil'" 60 90 "p-value `p_nobrazil'", place(se)) legend(off)
gr_edit note.style.editstyle size(vsmall) editcopy
graph export "Figure_2c.pdf", as(pdf) name("Graph") replace

* Upper Secondary

eststo: reg mean_act_class_min day_of_school_lost  if pandemic==1 & cntr!=2 & schoolkid==4
***
quietly summ mean_act_class_min 				   if pandemic==1 & cntr!=2 & schoolkid==4				
loc mymean: di %8.2f r(mean) 	
estadd loc mD `mymean', replace
loc mysd: di %8.2f r(sd) 
estadd loc mS `mysd', replace
***
quietly summ day_of_school_lost 				   if pandemic==1 & cntr!=2 & schoolkid==4				
loc mymean_X: di %8.2f r(mean) 	
estadd loc mD_X `mymean_X', replace
loc mysd_X: di %8.2f r(sd) 
estadd loc mS_X `mysd_X', replace
***
local b_nobrazil: di %3.2f _b[day_of_school_lost]
local t = _b[day_of_school_lost]/_se[day_of_school_lost]
local p_nobrazil: di %3.2f 2*ttail(e(df_r),abs(`t'))

twoway (scatter mean_act_class_min day_of_school_lost if pandemic==1 & schoolkid==4 & cntr!=2 & cntr!=6, mlabel(cntr) mlabsize(small)) ///
	   (scatter mean_act_class_min day_of_school_lost if pandemic==1 & schoolkid==4 & cntr==6, mlabel(cntr) mlabsize(small) ///
	   mlabposition(6) mcolor(navy) mlabcolor(navy)) ///
	   (lfit mean_act_class_min day_of_school_lost if pandemic==1 & schoolkid==4 & cntr!=2, lpattern(dash) ), ///
	xtitle(Days of school closure during the pandemic in 2020, size(medium)) ytitle(Minutes of online teaching activities, size(medium)) ///
	graphregion(color(white)) yscale(range(0 260))  ylabel(0(60)240) xscale(range(0 120)) xlabel(0(30)120) text(75 90 "slope:  `b_nobrazil'" 60 90 "p-value `p_nobrazil'", place(se)) legend(off)
gr_edit note.style.editstyle size(vsmall) editcopy
graph export "Figure_2d.pdf", as(pdf) name("Graph") replace

restore

/* Figure_S1: Days of School Closure and Cultural Dimensions */

preserve
collapse (mean) mean_act_class=act_class (mean) day_of_school_lost Percentagehhwithinternetacce Percentagehhwithbroadband fememploymentQ42019 motheremployment if pandemic==1 &  inrange(schoolkid,2,4),  by(cntr pandemic) 

sort cntr pandemic
order cntr pandemic

* Figure_S1a Broadband Availability
   
eststo clear
eststo: reg Percentagehhwithbroadband day_of_school_lost   if pandemic==1 & cntr!=2 
***
quietly summ Percentagehhwithbroadband					   if pandemic==1 & cntr!=2 	
loc mymean: di %8.2f r(mean) 	
estadd loc mD `mymean', replace
loc mysd: di %8.2f r(sd) 
estadd loc mS `mysd', replace
***
quietly summ day_of_school_lost 				  		   if pandemic==1 & cntr!=2 			
loc mymean_X: di %8.2f r(mean) 	
estadd loc mD_X `mymean_X', replace
loc mysd_X: di %8.2f r(sd) 
estadd loc mS_X `mysd_X', replace
***
local b_nobrazil: di %3.2f _b[day_of_school_lost]
local t = _b[day_of_school_lost]/_se[day_of_school_lost]
local p_nobrazil: di %3.2f 2*ttail(e(df_r),abs(`t'))

twoway (scatter Percentagehhwithbroadband day_of_school_lost if pandemic==1 & cntr!=2 & cntr!=6, mlabel(cntr) mlabsize(small)) ///
	   (scatter Percentagehhwithbroadband day_of_school_lost if pandemic==1 & cntr==6, mlabel(cntr) mlabsize(small) ///
	   mlabposition(6) mcolor(navy) mlabcolor(navy)) ///
	   (lfit Percentagehhwithbroadband day_of_school_lost if pandemic==1 & cntr!=2, lpattern(dash) ), ///
	xtitle(Days of school closure during the pandemic in 2020, size(medium)) ytitle(Percentage of HHs with broadband, size(medium)) ///
	graphregion(color(white)) yscale(range(80 100)) ylabel(80(5)100) xscale(range(0 120)) xlabel(0(30)120) text(98 90 "slope:  `b_nobrazil'" 97 90 "p-value `p_nobrazil'", place(se)) legend(off)
gr_edit note.style.editstyle size(vsmall) editcopy
graph export "Figure_S1a.pdf", as(pdf) name("Graph") replace

restore

* Figure_S1b: Teachers' Level of Digitization

preserve
collapse (mean) mean_act_class= act_class (mean) day_of_school_lost school_tech  if pandemic==1 & inrange(schoolkid,2,4),  by(cntr pandemic)  

sort cntr pandemic
order cntr pandemic

eststo clear
eststo: reg school_tech day_of_school_lost   		if pandemic==1 & cntr!=2 
***
quietly summ school_tech					  	    if pandemic==1 & cntr!=2 	
loc mymean: di %8.2f r(mean) 	
estadd loc mD `mymean', replace
loc mysd: di %8.2f r(sd) 
estadd loc mS `mysd', replace
***
quietly summ day_of_school_lost 				  		    if pandemic==1 & cntr!=2 			
loc mymean_X: di %8.2f r(mean) 	
estadd loc mD_X `mymean_X', replace
loc mysd_X: di %8.2f r(sd) 
estadd loc mS_X `mysd_X', replace
***
local b_nobrazil: di %3.2f _b[day_of_school_lost]
local t = _b[day_of_school_lost]/_se[day_of_school_lost]
local p_nobrazil: di %3.2f 2*ttail(e(df_r),abs(`t'))

twoway (scatter school_tech day_of_school_lost if pandemic==1 & cntr!=2, mlabel(cntr) mlabsize(small)) ///
	   (lfit school_tech day_of_school_lost if pandemic==1 & cntr!=2, lpattern(dash) ), ///
	xtitle(Days of school closure during the pandemic in 2020, size(medium)) ytitle(School-teacher Digitalization, size(medium)) ///
	graphregion(color(white)) yscale(range(-1 1.5)) ylabel(-1(0.5)1.5) xscale(range(0 120)) xlabel(0(30)120) text(1.4 90 "slope:  `b_nobrazil'" 1.2 90 "p-value `p_nobrazil'", place(se)) legend(off)
gr_edit note.style.editstyle size(vsmall) editcopy
graph export "Figure_S1b.pdf", as(pdf) name("Graph") replace

restore

/* Figure_S2: Days of School Closure and Female Labor Force Participation */

* Overall
   
preserve
collapse (mean) mean_act_class= act_class (mean) day_of_school_lost  Percentagehhwithinternetacce Percentagehhwithbroadband fememploymentQ42019 motheremployment if pandemic==1 & inrange(schoolkid,2,4),  by(cntr pandemic)  

sort cntr pandemic
order cntr pandemic  
   
eststo clear
eststo: reg fememploymentQ42019 day_of_school_lost   		if pandemic==1 & cntr!=2 
***
quietly summ fememploymentQ42019						   	if pandemic==1 & cntr!=2 	
loc mymean: di %8.2f r(mean) 	
estadd loc mD `mymean', replace
loc mysd: di %8.2f r(sd) 
estadd loc mS `mysd', replace
***
quietly summ day_of_school_lost 				  		   	if pandemic==1 & cntr!=2 			
loc mymean_X: di %8.2f r(mean) 	
estadd loc mD_X `mymean_X', replace
loc mysd_X: di %8.2f r(sd) 
estadd loc mS_X `mysd_X', replace
***
local b_nobrazil: di %3.2f _b[day_of_school_lost]
local t = _b[day_of_school_lost]/_se[day_of_school_lost]
local p_nobrazil: di %3.2f 2*ttail(e(df_r),abs(`t'))

twoway (scatter fememploymentQ42019 day_of_school_lost if pandemic==1 & cntr!=2 & cntr!=6, mlabel(cntr) mlabsize(small)) ///
	   (scatter fememploymentQ42019 day_of_school_lost if pandemic==1 & cntr==6, mlabel(cntr) mlabsize(small) ///
	   mlabposition(6) mcolor(navy) mlabcolor(navy)) ///
	   (lfit fememploymentQ42019 day_of_school_lost if pandemic==1 & cntr!=2, lpattern(dash) ), ///
	xtitle(Days of school closure during the pandemic in 2020, size(medium)) ytitle(Female labor force participation in 2019, size(medium)) ///
	graphregion(color(white)) yscale(range(40 90)) ylabel(40(10)90) xscale(range(0 120)) xlabel(0(30)120) text(85 90 "slope:  `b_nobrazil'" 82 90 "p-value `p_nobrazil'", place(se)) legend(off)
gr_edit note.style.editstyle size(vsmall) editcopy
graph export "Figure_S2a.pdf", as(pdf) name("Graph") replace

restore

* By school level
preserve

collapse (mean) mean_act_class= act_class (mean) day_of_school_lost  Percentagehhwithinternetacce Percentagehhwithbroadband fememploymentQ42019 motheremployment if pandemic==1 & inrange(schoolkid,2,4),  by(cntr pandemic schoolkid)  

* Primary 

eststo clear
eststo: reg fememploymentQ42019 day_of_school_lost   		if pandemic==1 & cntr!=2 & schoolkid==2
***
quietly summ fememploymentQ42019						   	if pandemic==1 & cntr!=2 & schoolkid==2	
loc mymean: di %8.2f r(mean) 	
estadd loc mD `mymean', replace
loc mysd: di %8.2f r(sd) 
estadd loc mS `mysd', replace
***
quietly summ day_of_school_lost 				  		   	if pandemic==1 & cntr!=2 & schoolkid==2			
loc mymean_X: di %8.2f r(mean) 	
estadd loc mD_X `mymean_X', replace
loc mysd_X: di %8.2f r(sd) 
estadd loc mS_X `mysd_X', replace
***
local b_nobrazil: di %3.2f _b[day_of_school_lost]
local t = _b[day_of_school_lost]/_se[day_of_school_lost]
local p_nobrazil: di %3.2f 2*ttail(e(df_r),abs(`t'))

twoway (scatter fememploymentQ42019 day_of_school_lost if pandemic==1 & cntr!=2 & cntr!=6 & schoolkid==2, ///
		mlabel(cntr) mlabsize(small)) ///
	   (scatter fememploymentQ42019 day_of_school_lost if pandemic==1 & cntr==6 & schoolkid==2, mlabel(cntr) mlabsize(small) ///
	   mlabposition(6) mcolor(navy) mlabcolor(navy)) ///
	   (lfit fememploymentQ42019 day_of_school_lost if pandemic==1 & cntr!=2 & schoolkid==2, lpattern(dash) ), ///
	xtitle(Days of school closure during the pandemic in 2020, size(medium)) ytitle(Female labor force participation in 2019, size(medium)) ///
	graphregion(color(white)) yscale(range(40 90)) ylabel(40(10)90) xscale(range(0 120)) xlabel(0(30)120) text(85 90 "slope:  `b_nobrazil'" 82 90 "p-value `p_nobrazil'", place(se)) legend(off)
gr_edit note.style.editstyle size(vsmall) editcopy
graph export "Figure_S2b.pdf", as(pdf) name("Graph") replace

* Lower Secondary

eststo clear
eststo: reg fememploymentQ42019 day_of_school_lost   		if pandemic==1 & cntr!=2 & schoolkid==3
***
quietly summ fememploymentQ42019						   	if pandemic==1 & cntr!=2 & schoolkid==3	
loc mymean: di %8.2f r(mean) 	
estadd loc mD `mymean', replace
loc mysd: di %8.2f r(sd) 
estadd loc mS `mysd', replace
***
quietly summ day_of_school_lost 				  		   	if pandemic==1 & cntr!=2 & schoolkid==3			
loc mymean_X: di %8.2f r(mean) 	
estadd loc mD_X `mymean_X', replace
loc mysd_X: di %8.2f r(sd) 
estadd loc mS_X `mysd_X', replace
***
local b_nobrazil: di %3.2f _b[day_of_school_lost]
local t = _b[day_of_school_lost]/_se[day_of_school_lost]
local p_nobrazil: di %3.2f 2*ttail(e(df_r),abs(`t'))

twoway (scatter fememploymentQ42019 day_of_school_lost if pandemic==1 & cntr!=2 & cntr!=6 & schoolkid==3, ///
		mlabel(cntr) mlabsize(small)) ///
	   (scatter fememploymentQ42019 day_of_school_lost if pandemic==1 & cntr==6 & schoolkid==3, mlabel(cntr) mlabsize(small) ///
	   mlabposition(6) mcolor(navy) mlabcolor(navy)) ///
	   (lfit fememploymentQ42019 day_of_school_lost if pandemic==1 & cntr!=2 & schoolkid==3, lpattern(dash) ), ///
	xtitle(Days of school closure during the pandemic in 2020, size(medium)) ytitle(Female labor force participation in 2019, size(medium)) ///
	graphregion(color(white)) yscale(range(40 90)) ylabel(40(10)90) xscale(range(0 120)) xlabel(0(30)120) text(85 90 "slope:  `b_nobrazil'" 82 90 "p-value `p_nobrazil'", place(se)) legend(off)
gr_edit note.style.editstyle size(vsmall) editcopy
graph export "Figure_S2c.pdf", as(pdf) name("Graph") replace

* Upper Secondary

eststo clear
eststo: reg fememploymentQ42019 day_of_school_lost   		if pandemic==1 & cntr!=2 & schoolkid==4
***
quietly summ fememploymentQ42019						   	if pandemic==1 & cntr!=2 & schoolkid==4	
loc mymean: di %8.2f r(mean) 	
estadd loc mD `mymean', replace
loc mysd: di %8.2f r(sd) 
estadd loc mS `mysd', replace
***
quietly summ day_of_school_lost 				  		   	if pandemic==1 & cntr!=2 & schoolkid==4			
loc mymean_X: di %8.2f r(mean) 	
estadd loc mD_X `mymean_X', replace
loc mysd_X: di %8.2f r(sd) 
estadd loc mS_X `mysd_X', replace
***
local b_nobrazil: di %3.2f _b[day_of_school_lost]
local t = _b[day_of_school_lost]/_se[day_of_school_lost]
local p_nobrazil: di %3.2f 2*ttail(e(df_r),abs(`t'))

twoway (scatter fememploymentQ42019 day_of_school_lost if pandemic==1 & cntr!=2 & cntr!=6 & schoolkid==4, ///
		mlabel(cntr) mlabsize(small)) ///
	   (scatter fememploymentQ42019 day_of_school_lost if pandemic==1 & cntr==6 & schoolkid==4, mlabel(cntr) mlabsize(small) ///
	   mlabposition(6) mcolor(navy) mlabcolor(navy)) ///
	   (lfit fememploymentQ42019 day_of_school_lost if pandemic==1 & cntr!=2 & schoolkid==4, lpattern(dash) ), ///
	xtitle(Days of school closure during the pandemic in 2020, size(medium)) ytitle(Female labor force participation in 2019, size(medium)) ///
	graphregion(color(white)) yscale(range(40 90)) ylabel(40(10)90) xscale(range(0 120)) xlabel(0(30)120) text(85 90 "slope:  `b_nobrazil'" 82 90 "p-value `p_nobrazil'", place(se)) legend(off)
gr_edit note.style.editstyle size(vsmall) editcopy
graph export "Figure_S2d.pdf", as(pdf) name("Graph") replace

restore

/* Figure_4: Online Teaching and Daily Activities */

preserve
collapse (mean) mean_act_class= act_class mean_act_hmwk_superv= act_hmwk_superv mean_act_hmwk_alone=act_hmwk_alone mean_homework=homework mean_delta_SH=delta_SH mean_delta_UH=delta_UH mean_delta_homework=delta_homework mean_delta_Extra=delta_Extra mean_delta_Other=delta_Other if inrange(schoolkid,2,4) & pandemic==1,  by(cntr pandemic)  
gen mean_homework_min		=mean_homework*60
gen mean_act_class_min		=mean_act_class*60
gen mean_delta_homework_min	=mean_delta_homework*60
gen mean_act_hmwk_superv_min=mean_act_hmwk_superv*60
gen mean_delta_SH_min		=mean_delta_SH*60
gen mean_act_hmwk_alone_min	=mean_act_hmwk_alone*60
gen mean_delta_UH_min		=mean_delta_UH*60
gen mean_delta_Extra_min	=mean_delta_Extra*60
gen mean_delta_Other_min	=mean_delta_Other*60

	la variable mean_act_class_min "Mins of Remote Leaning per day"
	
* Supervised Homework

reg mean_delta_SH_min mean_act_class_min if pandemic==1 & cntr!=8
est store RL_DSH_all
local b: di %3.2f _b[mean_act_class_min]
local t = _b[mean_act_class_min]/_se[mean_act_class_min]
local p: di %3.2f 2*ttail(e(df_r),abs(`t'))

twoway (scatter mean_delta_SH_min mean_act_class_min if pandemic==1 & cntr!=8, mlabel(cntr) mlabsize(small)) ///
	   (lfit mean_delta_SH_min mean_act_class_min if pandemic==1 & cntr!=8,lpattern(dash)), ///
	ytitle(Change in supervised homework (Min), size(medium)) ///
	xtitle(Minutes of online teaching activities, size(medium)) ///
	graphregion(color(white)) yscale(range(0 90))  ylabel(-30(30)90) xlabel(100(30)260) text(80 220 "slope:  `b'" 73 220 "p-value `p'", place(se)) legend(off)
gr_edit note.style.editstyle size(vsmall) editcopy
graph export "Figure_4a.pdf", as(pdf) name("Graph") replace

* Unsupervised Homework

reg mean_delta_UH_min mean_act_class_min if pandemic==1 & cntr!=8
est store RL_DUH_all
local b: di %3.2f _b[mean_act_class_min]
local t = _b[mean_act_class_min]/_se[mean_act_class_min]
local p: di %3.2f 2*ttail(e(df_r),abs(`t'))

twoway (scatter mean_delta_UH_min mean_act_class_min if pandemic==1 & cntr!=8, mlabel(cntr) mlabsize(small)) ///
	   (lfit mean_delta_UH_min mean_act_class_min if pandemic==1 & cntr!=8,lpattern(dash)), ///
	ytitle(Change in unsupervised homework (Min), size(medium)) ///
	xtitle(Minutes of online teaching activities, size(medium)) ///
	graphregion(color(white)) yscale(range(0 60))  ylabel(-30(30)90) xlabel(100(30)260) text(80 220 "slope:  `b'" 73 220 "p-value `p'", place(se)) legend(off)
gr_edit note.style.editstyle size(vsmall) editcopy
graph export "Figure_4b.pdf", as(pdf) name("Graph") replace

* Extracurricular Activities

reg mean_delta_Extra_min mean_act_class_min if pandemic==1 & cntr!=8
est store RL_DEx_all
local b: di %3.2f _b[mean_act_class_min]
local t = _b[mean_act_class_min]/_se[mean_act_class_min]
local p: di %3.2f 2*ttail(e(df_r),abs(`t'))

twoway (scatter mean_delta_Extra_min mean_act_class_min if pandemic==1 & cntr!=8, mlabel(cntr) mlabsize(small)) ///
	   (lfit 	mean_delta_Extra_min mean_act_class_min if pandemic==1 & cntr!=8,lpattern(dash)), ///
	ytitle(Change in extracurricular activities (Min), size(medium)) ///
	xtitle(Minutes of online teaching activities, size(medium)) ///
	graphregion(color(white)) yscale(range(0 30))  ylabel(-30(10)30) xlabel(100(30)260) text(20 220 "slope:  `b'" 15 220 "p-value `p'", place(se)) legend(off)
gr_edit note.style.editstyle size(vsmall) editcopy
graph export "Figure_4c.pdf", as(pdf) name("Graph") replace

* Other Activities

reg mean_delta_Other_min mean_act_class_min if pandemic==1 & cntr!=8
est store RL_DOt_all
local b: di %3.2f _b[mean_act_class_min]
local t = _b[mean_act_class_min]/_se[mean_act_class_min]
local p: di %3.2f 2*ttail(e(df_r),abs(`t'))

twoway (scatter mean_delta_Other_min mean_act_class_min if pandemic==1 & cntr!=8, mlabel(cntr) mlabsize(small)) ///
	   (lfit 	mean_delta_Other_min mean_act_class_min if pandemic==1 & cntr!=8,lpattern(dash)), ///
	ytitle(Change in other activities (Min), size(medium)) ///
	xtitle(Minutes of online teaching activities, size(medium)) ///
	graphregion(color(white)) yscale(range(0 60))  ylabel(-30(30)90) xlabel(100(30)260) text(80 220 "slope:  `b'" 73 220 "p-value `p'", place(se)) legend(off)
gr_edit note.style.editstyle size(vsmall) editcopy
graph export "Figure_4d.pdf", as(pdf) name("Graph") replace

restore